<?php
namespace app\member\controller;

use app\common\controller\MemberBase;
use app\common\model\UserSpread as cxModel;

class UserSpread extends MemberBase {

    //  会员中心首页
    public function index($t='puid'){
        if(request()->param('t')){
            $t = request()->param('t');
        }
        $map[$t] = $this->cxbsuser['uid'];
        $cxmodel = new cxModel();
        $zlist = $cxmodel->where($map)->order('id desc')->paginate('20',false,['query' => request()->param()])->each(function ($item){
            $item->username = model('User')->where('uid',$item->uid)->value('username');
            $item->username = substr($item->username,0,3)."****".substr($item->username,7,4);
            if(model('UserMoney')->where('fuid',$item->uid)->value('money')){
                $item->money = model('UserMoney')->where('fuid',$item->uid)->value('money');
            }else{
                $item->money = '0';
            }
        });
        $webs = array(
            'title' => '我的推广---'.$this->webdb['webname'],
            'keywords' => $this->webdb['webkeywords'],
            'description' => $this->webdb['description'],
        );
        $this->assign([
            'webs' => $webs,
            'list' => $zlist,
            't' => $t,
        ]);
        return view($this->temp.'user_spread.htm');
    }

    //  会员中心首页
    public function get_list(){
        $cxmodel = new cxModel();
        $zlist = $cxmodel->whereOr('puid',$this->cxbsuser['uid'])->whereOr('euid',$this->cxbsuser['uid'])->order('id desc')->paginate('20',false,['query' => request()->param()])->each(function ($item){
            $item->username = model('User')->where('uid',$item->uid)->value('username');
            $item->username = substr($item->username,0,3)."****".substr($item->username,7,4);
            if(model('UserMoney')->where('fuid',$item->uid)->value('money')){
                $item->money = model('UserMoney')->where('fuid',$item->uid)->value('money');
            }else{
                $item->money = '0';
            }
        });
        $webs = array(
            'title' => '我的推广---'.$this->webdb['webname'],
            'keywords' => $this->webdb['webkeywords'],
            'description' => $this->webdb['description'],
        );
        $this->assign([
            'webs' => $webs,
            'list' => $zlist,
        ]);
        return view($this->temp.'user_spreadlist.htm');
    }

}
